<?php
/**************************************************
* PluginLotto.com                                 *
* Copyrights (c) 2005-2010. iZAP                  *
* All rights reserved                             *
***************************************************
* @author iZAP Team "<support@izap.in>"
* @link http://www.izap.in/
* @version {version} $Revision: {revision}
* Under this agreement, No one has rights to sell this script further.
* For more information. Contact "Tarun Jangra<tarun@izap.in>"
* For discussion about corresponding plugins, visit http://www.pluginlotto.com/pg/forums/
* Follow us on http://facebook.com/PluginLotto and http://twitter.com/PluginLotto
 */

$poll = $vars['entity'];

//$metadata = get_metadata_for_entity($poll->guid);
//foreach($metadata as $data) {
//  echo $data['name'] . '->' . $data['value'] . '<br />';
//}

if($poll->description != '') { // checking if description is available or not
  $description = ucfirst($poll->description);
}
else {
  $description = '<i>'.elgg_echo('izap_poll:no_description').'</i>';
}

$html .= '<div class="contentWrapper">';
$html .= '<div class="poll_view_full">';
if($vars['result_only']) {
  $html .= elgg_view('output/result_only',array('entity' => $poll));
}else {
  $html .= func_izap_bridge_view('view/poll', array( 'entity' => $poll, 'plugin' => GLOBAL_IZAP_POLL_PLUGIN ));
}
$html .= '</div>';

$html .= '<div class="rate_view">'.elgg_view(
        'input/rate', array(
        'entity' => $poll
        )
);


$html .= func_izap_bridge_view(
        'view/actions',array(
        'plugin' => GLOBAL_IZAP_POLL_PLUGIN, 'entity' => $poll
        )
        ) . '<br />';


if($vars['result_only'] && !func_get_session_byizap($poll->guid)) {
  $html .= '<a href="'.$poll->getURL().'">' . elgg_echo('izap_poll:poll_now') . '</a><br />';
}elseif(!func_get_session_byizap($poll->guid)) {
  $html .= '<a href="'.func_set_href_byizap( array(
        'plugin' => GLOBAL_IZAP_POLL_PLUGIN,
        'page_owner' => $poll->getOwnerEntity()->username,
        'page' => 'result_only',
        'vars'=> array( $poll->guid ))).'">' . elgg_echo('izap_poll:view_result') . '</a><br />';
}
$html .= elgg_view('output/total_votes',array('entity' => $poll, 'remove_comments' => TRUE)).'<br />'; 
$html .= elgg_echo('izap_poll:comments').'<span class="hash_counting"> #'.elgg_count_comments($poll).'</span>';
$html .= '</div>';
$html .= '<div class="clearfloat"></div>';
$html .= '<div class="description_area">';
$html .= '<div class="f_left"><img src="'.$poll->getIcon().'" /></div>';
$html .= '<div class="time_line">'.elgg_echo('izap_poll:added_on').date("F d, Y",$poll->time_created).' '.elgg_echo('izap_poll:by').' <a href="'.$poll->getOwnerentity()->getUrl().'">'.$poll->getOwnerentity()->username.'</a> </div>';
$html .= '<div class="poll_description_view">'.$description.'</div>';
$html .= '<p class="tag_view"><img src="'.func_get_www_path_byizap(array('plugin' => GLOBAL_IZAP_POLL_PLUGIN, 'type' => 'images')).'icon_tag.gif" alt="Tags"/>'.elgg_view('output/tags', array('tags' => $poll->tags)).'</p>';
$html .= '<div class="clearfloat"></div>';
$html .= '</div></div>';
$html .= '<a name="comments"></a>';
$html .= elgg_view_comments($poll);
echo $html;
